using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.Skill
{
    public class SkillManager : MonoBehaviour
    {
        public List<Skill> availableSkills = new List<Skill>();
        private Dictionary<string, Skill> skillDictionary = new Dictionary<string, Skill>();
        private void Awake()
        {
            foreach (var skill in availableSkills)
            {
                skillDictionary.Add(skill.skillName, skill);
            }
        }
        public void CastSkill(string skillName)
        {
            if (skillDictionary.TryGetValue(skillName, out Skill skill))
            {
                if (skill.IsReady())
                {
                    skill.Activate(gameObject);
                }
            }
        }
        private void Update()
        {
            foreach (var skill in availableSkills)
            {
                skill.UpdateCooldown();
            }
        }
    }
}